<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script src="${pageContext.request.contextPath}/js/validateLand.js" type="text/javascript"></script>

<script type="text/javascript">

    $(document).ready(function () {
        validateLandDetails();

        /*if ($('#preferredAlienationMethod').val() > 0) {
         $('#alienationMethodsDivID').hide();
         }*/
    });

    function validateReject() {
        $("#gov-land-init-info-form").validate({
            rules: {
                approvalNote: {
                    required: true
                }
            },
            messages: {
                approvalNote: {
                    required: "Please enter a comment"
                }
            }
        });
    }

    function validateRejection() {
        var comment_on_rejection = $('#pls_enter_comment_on_rejection').val();

        $('#approvalCommentId').rules("add", {
            required: true,
            messages: {
                required: comment_on_rejection }
        });
    }

    /*$(function () {
        var leaseHtml = $('#leaseDetail').html();


        $('#leaseType0').bind('click', function () {
            //$('#leaseDetail').html(' ');
            alert(0);
            $('#leaseDetail').hide();
        });
        $('#leaseType1').bind('click', function () {
            ////$('#leaseDetail').html(leaseHtml);
            alert(1);
            $('#leaseDetail').show();
        });

        if ($('#leaseType0').is(':checked')) {
            $('#leaseDetail').html(' ');
        } else if ($('#leaseType1').is(':checked')) {
            $('#leaseDetail').html(leaseHtml);
        }

        if ($('#state').val() == 'DATA_ENTRY') {
            enableFields(new Array('leaseType0', 'leaseType1'));
        }
    });*/


</script>

<div id="land-registration-module-home-title" class="module-home-title">
    <s:a href="landRegistrationModule.do">
        <span><img src="${pageContext.request.contextPath}/images/land-reg.png" alt="Land Registration">
            <s:label value="%{getText('land_registration.label')}"/></span>
    </s:a>
    <span class="module-title-breaker"> > </span>
    <s:if test="((user.role.id != \"SC\")) ">
        <s:a href="approveLandList.do">
        <span><img src="${pageContext.request.contextPath}/images/accept.png" alt="Approve Land Information">
        <s:label value="%{getText('approve_land_info.label')}"/></span>
        </s:a>
        <div id="back-button" align="right">
            <s:form><s:submit value="%{getText('back_btn.label')}" action="approveLandList"/></s:form>
        </div>
    </s:if>
    <s:else>

        <s:a href="initForm.do">
                <span><img src="${pageContext.request.contextPath}/images/init-form.png" alt="Enter Land Information">
                    <s:label value="%{getText('enter_initial_land_info.label')}"/></span>
        </s:a>
        <div id="back-button" align="right">
            <s:form><s:submit value="%{getText('back_btn.label')}" action="landRegistrationModule"/></s:form>
        </div>
    </s:else>


</div>
<div id="init-land-outer" class="form-outer">
    <s:if test="hasActionErrors()">
        <s:div id="message-box" class="message-box">
            <div class="action-err">
                <s:label value="%{getText('error_occurred.label')}"/>
                <s:actionerror/>
            </div>
        </s:div>
    </s:if>
    <s:if test="hasActionMessages()">
        <s:div id="message-box2" class="message-box">
            <div class="action-msg">
                <s:actionmessage/>
            </div>
        </s:div>
    </s:if>
    <s:if test="%{warningDuplicates.size()>0}">
        <s:div id="message-box" class="message-box">
            <div class="action-warn">
                <label id="">Warning</label>
                <ul>
                    <s:iterator value="warningDuplicates">
                        <li><s:property value="message"/>&nbsp;<s:a href="loadRailwayLandDetails.do?landId=%{fileId}"><s:property value="file"/></s:a></li>
                    </s:iterator>
                </ul>
            </div>
        </s:div>
    </s:if>
    <div id="messageBox" class="action-msg"></div>
    <s:form method="POST" id="gov-land-init-info-form" name="init-land-info" enctype="multipart/form-data"
            onsubmit="javascript:return validateFormForInputDataSyntaxErrors('gov-land-init-info-form')">

        <s:if test="((user.role.id != \"SC\")) ">
            <h2><s:label value="%{getText('approve_land_info.label')}"/></h2>
        </s:if>
        <s:else>
            <h2><s:label value="%{getText('init_land_info.label')}"/></h2>
        </s:else>
        <s:if test="%{land.migrationState.ordinal() == 2}">
             <div style="color: #b94a48;background-color: #f2dede;border-color: #eed3d7;">
                 <s:label value="%{getText('This Land File has Migrated From Excel Sheet')}"/>
             </div>
        </s:if>
        <s:elseif test="%{land.migrationState.ordinal() == 1}">
            <div style="color: #3a87ad;background-color: #d9edf7;border-color: #bce8f1;">
                <s:label value="%{getText('This Land File has Migrated From Access Database')}"/>
            </div>
        </s:elseif>

        <s:include value="railway/landDetails.jsp"/>

    <%--<table class="width-100">

        <tr>

            <td class="left-align"><s:label value="Lease Type"/><span class="mandatory-field"></span></td>
            <td>
                <s:radio id="leaseType" name="land.leaseType"
                         list="#@java.util.HashMap@{'1':getText('withLease.label'),'0':getText('withoutLease.label')}"
                         value="1"/>
            </td>

        </tr>
    </table>--%>

        <%--<table id="leaseDetail" class="width-100">
            <tr>
                <td>
                    <s:include value="railway/railwayAlienationDetail.jsp"/>
                </td>
            </tr>
        </table>--%>

        <s:include value="railway/railwayAlienationDetail.jsp"/>


        <s:if test="land.approvalNote != null && land.approvalNote.length() > 0">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments_history.label')}"/></td>
                    <td colspan="3">
                        <s:textarea id="approvalNote" readonly="true" name="land.approvalNote" cssClass="width-595-px"/>
                    </td>
                </tr>
            </table>
        </s:if>

        <s:if test="((user.role.id != \"SC\")) ">
            <table class="width-100">
                <tr>
                    <td><s:label value="%{getText('comments.label')}"/></td>
                    <td colspan="3"><s:textarea id="approvalCommentId" name="approvalComment"
                                                cssClass="width-595-px"/></td>
                </tr>
            </table>
        </s:if>

        <div class="form-button-div right-align">
            <s:if test="editMode == 2">
                <s:submit cssClass="cancel" action="searchModule" value="%{getText('cancel.label')}"/>
            </s:if>
            <s:else>

                <s:if test="((user.role.id != \"SC\")) ">
                    <s:submit value="%{getText('approve.label')}" action="approveLandRailwayInformation"/>
                    <s:submit value="%{getText('reject.label')}" action="rejectLandRailwayInformation"
                              onclick="javascript:return validateRejection()"/>

                </s:if>
                <s:else>

                    <s:if test="(land.state.ordinal()==2 || land.state.ordinal()==1)">
                        <s:submit action="updateLandRailwayInformation" value="Update"
                                  onclick="validateFields()"/>
                        <s:submit cssClass="cancel" action="detailForm" value="%{getText('cancel.label')}"/>
                    </s:if>
                    <s:else>
                        <s:submit action="saveLandRailwayInformation" value="%{getText('save.label')}"
                                  onclick="validateFields()"/>
                        <s:submit cssClass="cancel" action="home" value="%{getText('cancel.label')}"/>
                    </s:else>

                </s:else>

            </s:else>

        </div>
    </s:form>


</div>
<s:hidden id="pls_enter_reference_no" value="%{getText('pls_enter_reference_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_valid_no" value="%{getText('pls_enter_valid_no')}"/>
<s:hidden id="pls_enter_name_of_the_land" value="%{getText('pls_enter_name_of_the_land')}"/>
<s:hidden id="pls_enter_plan_no" value="%{getText('pls_enter_plan_no')}"/>
<s:hidden id="pls_enter_lot_no" value="%{getText('pls_enter_lot_no')}"/>
<s:hidden id="pls_select_gn_division" value="%{getText('pls_select_gn_division')}"/>
<s:hidden id="pls_enter_valid_lot_no" value="%{getText('pls_enter_valid_lot_no')}"/>
<s:hidden id="userRole" name="user.role.id"/>
<s:hidden id="pls_enter_comment_on_rejection" value="%{getText('pls_enter_comment_on_rejection.label')}"/>
<%--<s:hidden id="pls_select_alienation_method" value="%{getText('pls_select_alienation_method.label')}"/>--%>

<s:hidden id="select" value="%{getText('select.label')}"/>
<s:hidden id="editMode" name="editMode"/>